package cn.wyl.org.domain;

import cn.wyl.basic.domain.BaseDomain;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
@Data //注在类上，提供类的getter、setter、equals、hashCode、toString方法和无参构造
/*@AllArgsConstructor：注在类上，提供类的全参构造
@NoArgsConstructor：注在类上，提供类的无参构造
@Setter：注在属性上，提供 set 方法
@Getter：注在属性上，提供 get 方法
@EqualsAndHashCode：注在类上，提供对应的equals和hashCode方法*/

@NoArgsConstructor
public class Department extends BaseDomain{
    //部门id
    //部门编号
    private String sn;
    //部门名称
    private String name;
    //部门路径
    private String dirPath;
    //部门状态：1启用,0禁用
    private Integer state = 1;
    //部门经理ID
    private Long manager_id;
    private Employee manager;

    //上级部门ID
    private Long parent_id;
    private Department parent;

    //子集部门
    //用于封装当前部门的子部门
    //部门树最后一级没有数据就不显示
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Department> children=new ArrayList<>();

    public Department(Long id,String sn, String name, String dirPath, Integer state, Long manager_id, Employee manager, Long parent_id, Department parent, List<Department> children) {
        super(id);
        this.sn = sn;
        this.name = name;
        this.dirPath = dirPath;
        this.state = state;
        this.manager_id = manager_id;
        this.manager = manager;
        this.parent_id = parent_id;
        this.parent = parent;
        this.children = children;
    }
}

